<template>
  <div>
    <el-form ref="garageForm" :model="form" label-width="80px">
      <el-row>
        <el-col :md="7" :lg="7">
          <el-form-item label="车辆品牌:">
            <el-select
              v-model="form.cartype0"
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in CarNameList()"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="7">
          <el-form-item label="车辆类型:">
            <el-select
              v-model="form.cartype1"
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in CarTypeList()"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="7">
          <el-form-item label="创建日期:">
            <el-date-picker
              v-model="form.ctime"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
        <el-col :md="3" :lg="3" style="text-align: right">
          <el-button
            type="primary"
            size="medium"
            @click="onSubmit('garageForm')"
          >
            搜索
          </el-button>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import mixin from '@/mixin/mixin'
export default {
  name: 'GarageForm',
  mixins: [mixin],
  data() {
    return {
      form: {
        cartype0: '',
        cartype1: '',
        ctime: ''
      }
    }
  },
  methods: {
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            cartype0: this.form.cartype0,
            cartype1: this.form.cartype1,
            ctime: this.form.ctime
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style scoped>
  .el-input {
    width: 160px;
  }
</style>
